|
|
|
|
|
|
|
Circle (x, y), r, , -arcstart * PI / 180, -arcend * PI / 180
Next nCount
Me.Caption = "Done"
End Sub |
|
|
|
|
|
|
|
|
Although you might not traditionally associate the Print method with graphics because it produces text, it is a graphics method in that it "draws" the text on your object like any other graphics method. You can use the Print method in conjunction with other graphics methods to create charts or drawings or to annotate existing bitmaps. The Print method itself is quite simple. The following code displays a single line of text at the current position on the form: |
|
|
|
|
|
|
|
|
Print "This is a one-line test." |
|
|
|
|
|
|
|
|
The output of the Print method is controlled by the properties of the object being printed on. These properties are as follow: |
|
|
|
|
|
|
|
|
CurrentX. This property sets the horizontal position for the starting point of the text. |
|
|
|
|
|
|
|
|
CurrentY. This property sets the vertical position for the starting point of the text. |
|
|
|
|
|
|
|
|
Font. This property determines the font type and size used for the text. |
|
|
|
|
|
|
|
|
ForeColor. This property determines the color of the text. |
|
|
|
|
|
|
|
|
FontTransparent. On a form or picture, this property determines whether the background behind the text shows through the spaces in the text. |
|
|
|
|
|
|
|
|
You can experiment with printing and other graphics methods by using Visual Basic's Immediate window. Follow these steps: |
|
|
|
|
|
|
|
|
1. Create a new project and add a PictureBox control. |
|
|
|
|
|
|
|
|
2. Set the form and picture box's AutoRedraw properties to True. |
|
|
|
|
|
|
|
|
3. Run your project and then press Ctrl+Break. |
|
|
|
|
|
|
|
|
4. Enter code statements that use graphics methods in the Immediate window: |
|
|
|
|
|
|
|
|
form1.print "Hey"
picture1.Print "Now" |
|
|
|
|
|
|
|
|
You can use the PSet method to draw a single point on the form using the color specified by the ForeColor property. The size of the point drawn is dependent on the setting of the DrawWidth property. A larger DrawWidth setting produces a larger point. The PSet method draws the point at the coordinates specified in the argument of the method. The following code draws 100 points at random positions on the current form: |
|
|
|
|
|
|
|
|
Dim i As Integer, x As Integer, y As Integer
Me.DrawWidth = 5
For i = 1 To 100
'Choose random x and y
x = Int(Me.ScaleWidth + 1) * Rnd
y = Int(Me.ScaleHeight + 1) * Rnd
PSet (x, y)
Next i |
|
|
|
|
|